<include file="public:header" />
<script type="text/javascript" src="__ROOT__/statics/js/jquery/plugins/jquery.imagePreview.js"></script>
<div class="pad-lr-10">
	 <form name="searchform" action="" method="get" >
    <table width="100%" cellspacing="0" class="search-form">
        <tbody>
            <tr>
            <td>
            <div class="explain-col">   
				{:L(goods_type)} :				
					<select name="goods_type">
						<option value="0" selected="selected">--商品类型--</option>
						<option value="1" <if condition="$goods_type eq 1">selected="selected"</if>>{:L(goods_type_0)}</option>
						<option value="2" <if condition="$goods_type eq 2">selected="selected"</if>>{:L(goods_type_1)}</option>
					</select>			
                &nbsp;关键字 :
                <input name="keyword" type="text" class="input-text" size="25" value="{$keyword}" />
                <input type="hidden" name="m" value="exchange_goods" />
                <input type="submit" name="search" class="button" value="搜索" />
        	</div>
            </td>
            </tr>
        </tbody>
    </table>
    </form>	
    <form id="myform" name="myform" action="{:u('exchange_goods/delete')}" method="post" onsubmit="return check();">
    <div class="table-list">
    <table width="100%" cellspacing="0">
        <thead>
            <tr>
                <th width=50>ID</th>
                <th width=30><input type="checkbox" value="" id="check_box" onclick="selectall('id[]');"></th>				
                <th width=60>{:L('name')}</th>				
                <th width=100>{:L('goods_type')}</th>
				<th width=120>{:L('img')}</th>
                <th>{:L('integral')}</th>
				<th>{:L('stock')}</th>
				<th>{:L('buy_count')}</th>
				<th>{:L('user_num')}</th>
				<th>{:L('begin_time')}</th>
				<th>{:L('end_time')}</th>				     
				<th width=60>排序</th> 			
                <th width=60>状态</th>				
                <th width=60>操作</th>
            </tr>
        </thead>
    	<tbody>
        <volist name="ex_goods_list" id="val" key='k' >
        <tr>
        	<td align="center">{$val.id}</td>
            <td align="center"><input type="checkbox" value="{$val.id}" name="id[]" </td>                    
            <td align="center">{$val.name}</td> 
			<td align="center"><if condition="$val.goods_type eq 1">实体商品<else /> 虚拟商品</if></td>
			<td align="center"><a href="{:u('exchange_goods/edit',array('id'=>$val['id']))}"><notempty name="val.img"> <img src="{$val.img}" style="border: 1px solid #999999;padding:1px;width:80px;height:80px;" class="preview" bimg="{$val.img}" /></notempty></img></td>   		
			<td align="center">{$val.integral}</td>
			<td align="center">{$val.stock}</td>
			<td align="center">{$val.buy_count}</td>
			<td align="center">{$val.user_num}</td>
			<td align="center">{$val.begin_time|date="Y-m-d",###}</td>
			<td align="center">{$val.end_time|date="Y-m-d",###}</td>
			<td align="center"><input type="text" class="input-text-c input-text" onblur="sort({$val.id},'sort',this.value)" id="sort_{$val.id}" value="{$val.sort}" size="4" name="listorders[{$val.id}]"></td>
            <td align="center" onclick="status({$val.id},'status')" id="status_{$val.id}"><img src="__ROOT__/statics/images/status_{$val.status}.gif" /></td>
            <td align="center"><a href="{:u('exchange_goods/edit',array('id'=>$val['id']))}">编辑</a></td>
        </tr>
        </volist>
    	</tbody>
    </table>
    <div class="btn">
		<label for="check_box" style="float:left;">{$Think.lang.select_all}/{$Think.lang.cancel}</label>
		<input type="submit" class="button" name="dosubmit" value="{$Think.lang.delete}" onclick="return confirm('{$Think.lang.sure_delete}')" style="float:left;margin-left:10px;"/>
		<div id="pages">{$page}</div>
    </div>
    </div>
    </form>
</div>
<script language="javascript">
$(function(){
	$(".preview").preview();
});

function check(){
	var ids='';
	$("input[name='id[]']:checked").each(function(i, n){
		ids += $(n).val() + ',';
	});
	if(ids=='') {
		window.top.art.dialog({content:lang_please_select+'菜单分类名称	',lock:true,width:'200',height:'50',time:1.5},function(){});
		return false;
	}
	return true;
}
function edit(id, name) {
	var lang_edit = "{$Think.lang.edit}";
	window.top.art.dialog({id:'edit'}).close();
	window.top.art.dialog({
		title:lang_edit+'--'+name,
		id:'edit',
		iframe:'?m=exchange_goods&a=edit&id='+id,width:'480',height:'170'
		}, 
		function()
		{
			var d = window.top.art.dialog({id:'edit'}).data.iframe;
			d.document.getElementById('dosubmit').click();
			return false;
		}, 
		function()
		{
			window.top.art.dialog({id:'edit'}).close()
		});
}
function status(id,type){
    $.get("{:u('exchange_goods/status')}", { id: id, type: type }, function(jsondata){
		var return_data  = eval("("+jsondata+")");
		$("#"+type+"_"+id+" img").attr('src', '__ROOT__/statics/images/status_'+return_data.data+'.gif');
	}); 
}
//排序方法
function sort(id,type,num){
    $.get("{:u('exchange_goods/sort')}", { id: id, type: type,num:num }, function(jsondata){
		$("#"+type+"_"+id+" ").attr('value', jsondata.data);
	},'json'); 
}
</script>
</body>
</html>